home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Starter / SprocketStarter Code / TextWindow.h < prev    next >
Text File  |  1996-06-12  |  4KB  |  166 lines

  1. /*
  2. ** File:        TextWindow.h
  3. **
  4. ** Written by:    Bill Hayden
  5. **                Nikol Software
  6. **
  7. ** Copyright © 1995-1996 Nikol Software
  8. ** All rights reserved.
  9. */
  10.  
  11.  
  12. #pragma once
  13.  
  14. #include "Window.h"
  15. #include "UTextWindow.h"
  16. #include "WASTE.h"
  17.  
  18. #include "File.h"
  19.  
  20.  
  21. class    TTextWindow    :    public    TWindow
  22. {
  23. public:
  24.                         TTextWindow(void);
  25.     virtual                ~TTextWindow();
  26.     
  27.     
  28.                 //OSErr    ITextWindow(void);
  29.                 OSErr    ITextWindow(FSSpecPtr filespec = nil);
  30.  
  31.  
  32.     //    Event routing methods
  33.  
  34.     virtual    Boolean        EventFilter(EventRecord * theEvent);
  35.  
  36.  
  37.     //    Methods which MUST be overridden:
  38.  
  39.     virtual WindowRef    MakeNewWindow(WindowRef behindWindow);
  40.     
  41.  
  42.     //    Methods which probably should be overridden
  43.  
  44.     virtual    void        AdjustCursor(EventRecord * anEvent);
  45.     virtual void        Idle(EventRecord * anEvent);
  46.     virtual void        Activate(Boolean activating);
  47.     virtual void        Draw(void);
  48.     virtual    void        KeyDown(EventRecord * anEvent);
  49.  
  50.     virtual void        GetPerfectWindowSize(Rect * perfectSize);
  51.     virtual    void        GetWindowSizeLimits(Rect * limits);
  52.     virtual void        AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
  53.     virtual void        Click(EventRecord * anEvent);
  54.  
  55.  
  56.     //    Window property accessor methods…
  57.     
  58.     virtual    Boolean        CanClose(Boolean quitting);        
  59.     virtual    Boolean        Close(void);
  60.     //virtual    Boolean        DeleteAfterClose(void);
  61.     
  62.     //    Methods for handling menus & menu commands
  63.     
  64.     virtual    void        AdjustMenusBeforeMenuSelection(void);
  65.     virtual Boolean        DoMenuSelection(short menu, short item);
  66.     virtual Boolean        DoCommand(CommandID theCommand);
  67.  
  68.     //    Methods for use with the Drag Manager
  69.     
  70.     virtual    OSErr        DragEnterWindow(DragReference theDrag);
  71.     virtual    OSErr        DragInWindow(DragReference theDrag);
  72.     virtual    OSErr        DragLeaveWindow(DragReference theDrag);
  73.  
  74.     virtual    OSErr        HandleDrop(DragReference theDragRef);
  75.  
  76.     //virtual Boolean        IsPointInContentRgn( Point pt );
  77.     //virtual Boolean        IsMouseInContentRgn( DragReference dragRef );
  78.     
  79.             void        GetWERect(LongRect& teRect);
  80.     
  81.             Boolean        HaveSelection();
  82.                 
  83.             void        GetScrollBarRect( VHSelect axis, Rect *barRect );
  84.             void        GetTextRect( Rect *textRect );
  85.             void        GetGrowIconRect( Rect *iconRect );
  86.             void        ViewChanged( void );
  87.             void        AdjustBars( void );
  88.             void        ScrollBarChanged( void );
  89.             void        DoScrollKey( SignedByte keyCode );
  90.             void        DoScrollBar( Point hitPt, EventModifiers modifiers );
  91.             
  92.             OSErr        SafeSaveFile(Boolean replacing, FSSpec& filespec);
  93.     static    void        SetUpStaticMenu( void );
  94.  
  95. protected:
  96.     static    MenuRef        fFontMenu;
  97.     static    MenuRef        fSizeMenu;
  98.     static    MenuRef        fStyleMenu;
  99.     static    MenuRef        fColorMenu;
  100.  
  101.  
  102. public:
  103.     
  104.     WEHandle            fWEHandle;
  105.     TFile*                fBackingFile;
  106.     ControlRef            fDocHScroll;
  107.     ControlRef            fDocVScroll;
  108.     
  109.     ControlRef            fSaveButton;
  110.     
  111.     ControlRef            fLeftAlignButton;
  112.     ControlRef            fCenterAlignButton;
  113.     ControlRef            fRightAlignButton;
  114.     ControlRef            fJustifyButton;
  115.  
  116.     ControlRef            fPlainButton;
  117.     ControlRef            fBoldButton;
  118.     ControlRef            fItalicButton;
  119.     ControlRef            fUnderlineButton;
  120.  
  121.     ControlRef            fBlackButton;
  122.     ControlRef            fBlueButton;
  123.     ControlRef            fGreenButton;
  124.     ControlRef            fRedButton;
  125.     ControlRef            fPinkButton;
  126.     ControlRef            fOrangeButton;
  127.     ControlRef            fBrownButton;
  128.  
  129.     short                fToolbarHeight;        // for top toolbar
  130.     Str255                fName;
  131. };
  132.  
  133.  
  134.  
  135. enum
  136.     {
  137.     kStyleBase     = 700,
  138.     kSizeBase    = 600
  139.     };
  140.  
  141.  
  142. //    resource types, clipboard types, and file types
  143.  
  144. #define    kTypeDeskAccessory        'DRVR'
  145. #define    kTypeFont                'FONT'
  146. #define    kTypePicture            'PICT'
  147. #define    kTypeSound                'snd '
  148. #define kTypeSoup                'SOUP'
  149. #define kTypeStyles                'styl'
  150. #define kTypeText                'TEXT'
  151. #define kTypeTextReadOnly        'ttro'
  152.  
  153. //    virtual key codes for navigation keys found on extended keyboards
  154.  
  155. #define    keyPgUp        0x74
  156. #define keyPgDn        0x79
  157. #define keyHome        0x73
  158. #define keyEnd        0x77
  159.  
  160. //    virtual key codes generated by some function keys
  161.  
  162. #define    keyF1        0x7A
  163. #define keyF2        0x78
  164. #define keyF3        0x63
  165. #define keyF4        0x76
  166.